﻿using CleanArchitecture.Infrastructure.Entities.Customers;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CleanArchitecture.Infrastructure.DataMapping.Customers
{
    /// <summary>
    /// Represents a Customer mapping configuration
    /// </summary>
    public partial class CustomerMap : NowaEntityTypeConfiguration<Customer>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<Customer> builder)
        {
            builder.ToTable("customer");
            builder.HasKey(customer => customer.Id);

            builder.Property(customer => customer.CustomerName).HasMaxLength(50);
            builder.Property(customer => customer.CustomerLoginname).HasMaxLength(50).IsRequired();
            builder.Property(customer => customer.Mobile).HasMaxLength(50).IsRequired();
            builder.Property(customer => customer.Email).HasMaxLength(100).IsRequired();
            builder.Property(customer => customer.Password).HasMaxLength(1000).IsRequired();
            builder.Property(customer => customer.PasswordSalt).HasMaxLength(100);
            builder.Property(customer => customer.Birthday).HasMaxLength(50);
            builder.Property(customer => customer.LevelCode).HasMaxLength(50);
            builder.Property(customer => customer.LastLoginIp).HasMaxLength(50).IsRequired();
            builder.Ignore(customer => customer.PasswordFormat);
            base.Configure(builder);
        }

        #endregion
    }
}